package pishen;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

public class AuthorNode implements Node, Serializable {
	private static final long serialVersionUID = 1028681987125075958L;
	private String name;
	private double prestige;
	private ArrayList<CombineLink> linkList = new ArrayList<CombineLink>();
	private HashMap<String, CombineLink> linkMap = new HashMap<String, CombineLink>();

	public AuthorNode(String name) {
		this.name = name;
	}

	public void addLink(String target, double addedWeight) {
		if (linkMap.containsKey(target)) {
			linkMap.get(target).addWeight(addedWeight);
		} else {
			CombineLink newLink = new CombineLink(target, addedWeight);
			linkMap.put(target, newLink);
			linkList.add(newLink);
		}
	}

	@Override
	public String getLinkTarget(int index) {
		return linkList.get(index).getTarget();
	}

	@Override
	public double getLinkWeight(int index) {
		return linkList.get(index).getWeight();
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public int getNumOfLinks() {
		return linkList.size();
	}

	@Override
	public double getPrestige() {
		return this.prestige;
	}

	@Override
	public void setPrestige(double newPrestige) {
		this.prestige = newPrestige;
	}

}
